//删除字符串中的所有相邻重复项
//测试链接 https://leetcode.cn/problems/remove-all-adjacent-duplicates-in-string/
public class RemoveDuplicates {
    public char[] stack = new char[500000];
    public String removeDuplicates(String s) {
        int pos = 0;
        for(int i = 0; i < s.length(); i++){
            if(pos != 0 && stack[pos-1] == s.charAt(i)){
                pos--;
            }else{
                stack[pos++] = s.charAt(i) ;
            }
        }
        return new String(stack,0,pos);
    }
}
